﻿using KinonekoSoftware.CodariaDB.Documents.Keywords;

namespace KinonekoSoftware.Studio.Pages.Galleries.Teams
{
    public sealed class TeamGalleryViewModel : _LiteGallery
    {


        /*
         * InvalidateDataSource : OnStart、OnResume
         * InvalidatePageSource : SortBy、PageBy、SearchBy、PageIndex
         * InvalidatePageInfo
         *
         */

        public TeamGalleryViewModel() : base(InstanceType.Team)
        {

        }

        private static string ExtraTypeStringSelector(object value)
        {
            var v = (TeamType)(value is int n ? n : 0);
            return LanguageManager.GetEnum(v);
        }






        //-------------------------------------------------------------
        //
        //          Override Methods
        //
        //-------------------------------------------------------------


        protected override async void NewInstanceCommandOverride()
        {
            var type = Type == InstanceType.Instance ? InstanceType.Character : Type;
            var r = await Platform.NewInstance(type, new[]
            {
                (int)TeamType.Party,
                (int)TeamType.Kizuna,
                (int)TeamType.Grouped,
                (int)TeamType.Community,
                (int)TeamType.Gangs,
                (int)TeamType.GangsInClass,
                (int)TeamType.GangsInSchool,
                (int)TeamType.Composition,

            }, ExtraTypeStringSelector);

            if (!r.IsFinished)
            {
                return;
            }

            //
            // 
            var cache = r.Value;

            //
            // 添加 Cache
            _collection.Add(cache);
            _engine_cache.AddCache(cache);

            FullyCollection.Add(cache);
        }



        /// <summary>
        /// 重写当前方法，来自定义跳转。
        /// </summary>
        /// <param name="target">要打开的设定索引。</param>
        protected override void OpenInstance(InstanceCache target) => Platform.OpenTeam(target);












        //-------------------------------------------------------------
        //
        //          Properties
        //
        //-------------------------------------------------------------










        //-------------------------------------------------------------
        //
        //          Properties
        //
        //-------------------------------------------------------------





        //-------------------------------------------------------------
        //
        //          Commands
        //
        //-------------------------------------------------------------




    }
}